﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PersonalClient.Helper
{
    public class nativemethods
    {
        /// <summary>
        /// 带有外边框和标题的windows的样式
        /// </summary>
        public const long ws_caption = 0x00c0000;
        public const long ws_border = 0x0080000;
        /// <summary>
        /// window 扩展样式 分层显示
        /// </summary>
        public const long ws_ex_layered = 0x00080000;
        /// <summary>
        /// 带有alpha的样式
        /// </summary>
        public const long lwa_alpha = 0x00000002;
        /// <summary>
        /// 颜色设置
        /// </summary>
        public const long lwa_colorkey = 0x00000001;
        public const int CS_DropSHADOW = 0x20000;

        /// <summary>
        /// window的基本样式
        /// </summary>
        public const int gwl_style = -16;
        /// <summary>
        /// window的扩展样式
        /// </summary>
        public const int gwl_exstyle = -20;
        /// <summary>
        /// 设置窗体的样式
        /// </summary>
        /// <param name="handle">操作窗体的句柄</param>
        /// <param name="oldstyle">进行设置窗体的样式类型.</param>
        /// <param name="newstyle">新样式</param>
        [System.Runtime.InteropServices.DllImport("user32.dll")]
        public static extern void SetWindowLong(IntPtr handle, int oldstyle, long newstyle);
        /// <summary>
        /// 获取窗体指定的样式.
        /// </summary>
        /// <param name="handle">操作窗体的句柄</param>
        /// <param name="style">要进行返回的样式</param>
        /// <returns>当前window的样式</returns>
        [System.Runtime.InteropServices.DllImport("user32.dll")]
        public static extern long GetWindowLong(IntPtr handle, int style);
        /// <summary>
        /// 设置窗体的工作区域.
        /// </summary>
        /// <param name="handle">操作窗体的句柄.</param>
        /// <param name="handleregion">操作窗体区域的句柄.</param>
        /// <param name="regraw">if set to <c>true</c> [regraw].</param>
        /// <returns>返回值</returns>
        [System.Runtime.InteropServices.DllImport("user32.dll")]
        public static extern int SetWindowRgn(IntPtr handle, IntPtr handleregion, bool regraw);
        /// <summary>
        /// 创建带有圆角的区域.
        /// </summary>
        /// <param name="x1">左上角坐标的x值.</param>
        /// <param name="y1">左上角坐标的y值.</param>
        /// <param name="x2">右下角坐标的x值.</param>
        /// <param name="y2">右下角坐标的y值.</param>
        /// <param name="width">圆角椭圆的 width.</param>
        /// <param name="height">圆角椭圆的 height.</param>
        /// <returns>hrgn的句柄</returns>
        [System.Runtime.InteropServices.DllImport("gdi32.dll")]
        public static extern IntPtr CreateRoundRectRgn(int x1, int y1, int x2, int y2, int width, int height);
        /// <summary>
        /// sets the layered window attributes.
        /// </summary>
        /// <param name="handle">要进行操作的窗口句柄</param>
        /// <param name="colorkey">rgb的值</param>
        /// <param name="alpha">alpha的值，透明度</param>
        /// <param name="flags">附带参数</param>
        /// <returns>true or false</returns>
        [System.Runtime.InteropServices.DllImport("user32.dll")]
        public static extern bool SetLayeredWindowAttributes(IntPtr handle, ulong colorkey, byte alpha, long flags);
    }

}
